/*********************************************************
 * Cameron Hilton
 * CS362_400
 * 
 * Test to see if council room card has desired outcome in council_room_effect() function
 ********************************************************/

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int cardEffect(int card, int choice1, int choice2, int choice3, struct gameState *state, int handPos, int *bonus);
//int council_room_effect (int currentPlayer, struct gameState *state, int handPos);

int main() {
    
    int seed = 1000;
    int numPlayer = 2;
    int i;
    int bonus = 0;
    
	struct gameState state;
	int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};

	memset(&state, 23, sizeof(struct gameState)); // reset game state
	initializeGame(numPlayer, k, seed, &state);

	state.whoseTurn = 0;
	state.hand[0][0] = council_room; // ensure steward is in player's hand

	state.handCount[0] = 5;

	printf("Testing return value\n");
	//assert(council_room_effect(0, &state, 0) == 0);
	assert(cardEffect(council_room, 0, 0, 0, &state, 0, &bonus) == 0);

	memset(&state, 23, sizeof(struct gameState)); // reset game state
	initializeGame(numPlayer, k, seed, &state);
	state.handCount[0] = 5;

	printf("Testing hand count\n");
	//council_room_effect(0, &state, 0);
	cardEffect(council_room, 0, 0, 0, &state, 0, &bonus);
	assert(state.handCount[0] == 8);

	for (numPlayer = 2; numPlayer < 5; numPlayer++) {
		printf("Testing hand count for other players with %d total players\n", numPlayer);

		// give each player 5 cards to start with
		for (i = 1; i < numPlayer; i++) {
			memset(&state, 23, sizeof(struct gameState)); // reset game state
			initializeGame(numPlayer, k, seed, &state);
			state.handCount[i] = 5;
			cardEffect(council_room, 0, 0, 0, &state, 0, &bonus);
			//council_room_effect(0, &state, 0);
			assert(state.handCount[i] == 6);
		}
	}

    printf("All tests passed!\n");

    return 0;
}